﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;

namespace Yoozoo.Gameplay.City
{
    [Serializable]
    public class CitySubFog
    {
        public int fogId;
        public List<Vector2Int> grids;
    }
    
    [Serializable]
    public class CityFogConfig
    {
        public int width = 200;
        public int height = 200;
        public float fogSize = 10;
        public float fogPosY = 5.0f;
        public float fogOffsetX = -50;
        public float fogOffsetZ = -50;
        
        public List<CitySubFog> CitySubFogs;

        private Dictionary<int, CitySubFog> CitySubFogMap;

        public void FormatConfig()
        {
            CitySubFogMap = new Dictionary<int, CitySubFog>(CitySubFogs.Count);
            foreach (var subFog in CitySubFogs)
            {
                CitySubFogMap[subFog.fogId] = subFog;
            }
        }

        public List<Vector2Int> GetFogGrids(int fogId)
        {
            CitySubFog subFog = null;
            if (CitySubFogMap.TryGetValue(fogId, out subFog))
            {
                return subFog.grids;
            }
            return null;
        }
        

    }
}